﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace QLBH.DAO
{
    class Connecttion_Excel
    {
        public static string connectionString;
        public static OleDbConnection conn;
        public static OleDbCommand cmd;
        public static OleDbDataAdapter adap;
        public static DataTable dt;
        public static OleDbConnection StartConnect()
        {
            try
            {
                conn = new OleDbConnection(connectionString);
                return conn;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi kết nối " + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return conn;
        }
        public static OleDbConnection CloseConnection()
        {
            conn.Close();
            return conn;
        }
        public static DataTable GetDatatable(String sql)
        {

            adap = new OleDbDataAdapter(sql, conn);
            dt = new DataTable();
            adap.Fill(dt);
            return dt;  
        }
    }
}
